//
//  PlanCell.m
//  KuWoCan
//
//  Created by hwd on 17/3/6.
//  Copyright © 2017年 hwd. All rights reserved.
//

#import "PlanCell.h"

@interface PlanCell ()

@property (nonatomic,strong) UILabel *bigLab;

@property (nonatomic,strong) UILabel *numberLab;

@property (nonatomic,strong) UILabel *shenYuLab;

@property (nonatomic,strong) UILabel *timeLab;

@end


@implementation PlanCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        self.selectionStyle = 0;
    }
    return self;
    
}
-(void)loadCellWith:(NSDictionary *)dataDic
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    
    
    _bigLab = [[UILabel alloc]initWithFrame:CGRectMake(15*screenW_6, 20*screenW_6, 35*screenW_6, 35*screenW_6)];
    [self.contentView addSubview:_bigLab];
    _bigLab.font = [UIFont systemFontOfSize:10];
    _bigLab.textColor = [UIColor whiteColor];
    _bigLab.textAlignment = NSTextAlignmentCenter;
    [_bigLab.layer setCornerRadius:17.5*screenW_6];
    _bigLab.layer.masksToBounds = YES;
    _bigLab.text = @"一月";
    _bigLab.backgroundColor = [UIColor colorWithHexString:@"55aee7"];
    [self.contentView addSubview:_bigLab];
    
    _numberLab = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(_bigLab.frame)+10*screenW_6, 12.5*screenW_6, SCREENW-150*screenW_6, 25*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:15*screenW_6] textColor:[UIColor colorWithHexString:@"#333333"] text:[NSString stringWithFormat:@"目标回款：%@元",@"2"]];
    [self.contentView addSubview:_numberLab];
    
    _shenYuLab = [TomamaUI createLabel:CGRectMake(CGRectGetMaxX(_bigLab.frame)+10*screenW_6,CGRectGetMaxY(_numberLab.frame),SCREENW-150*screenW_6, 25*screenW_6) textAligment:0 font:[UIFont systemFontOfSize:15*screenW_6] textColor:[UIColor colorWithHexString:@"#55aee7"] text:[NSString stringWithFormat:@"实际回款：%@元",@"2"]];
    [self.contentView addSubview:_shenYuLab];

    _timeLab = [TomamaUI createLabel:CGRectMake(SCREENW-80*screenW_6 ,0,60*screenW_6,75*screenW_6) textAligment:2 font:[UIFont systemFontOfSize:14*screenW_6] textColor:[UIColor blackColor] text:@"100%"];
    [self.contentView addSubview:_timeLab];

    
}

- (NSString *)getMonthWithNum:(NSString *)number
{
//    NSArray *numberArr = @[@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12"];
    NSArray *monthArr = @[@"一月",@"二月",@"三月",@"四月",@"五月",@"六月",@"七月",@"八月",@"九月",@"十月",@"十一月",@"十二月"];
    if ([number integerValue] > 0)
    {
        NSString *monthStr = [monthArr objectAtIndex:[number integerValue]-1];
        return monthStr;
    }
    return @"一月";
}


- (void)setModel:(MissonComModel *)model
{
    _bigLab.text = [self getMonthWithNum:model.monthNum];
    _numberLab.text = [NSString stringWithFormat:@"目标回款：%@元",model.goal];
    _shenYuLab.text = [NSString stringWithFormat:@"实际回款：%@元",model.actual];
    CGFloat percent = 0;
    if ([model.goal integerValue] == 0)
    {
        percent = 0;
    }
    else
    {
        percent =[model.actual integerValue]/[model.goal integerValue];
    }

    _timeLab.text =  [NSString stringWithFormat:@"%.0f%%",percent*100];;
    
}



@end
